/////////////////////////////////////////////////////////////////////////////
// Purpose:     Improvement of std::vector
// Author:      Jesus Gonzalez
// Modified by:
// Copyright:   (c) 2003-2013 Jesus Gonzalez <jgonzalez@gdr-sistemas.com>
// License:     BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _SMARTLIB_SMARTVECTOR_H_
#define _SMARTLIB_SMARTVECTOR_H_

/**
 * \file
 * Improvement of std::vector.
 */

#include <vector>

/**
 * The SmartVector template class is an extension of the STL \p vector class that dynamically manages
 * the objects that it contains.
 */
template< typename T >
class SmartVector : public std::vector<T*>
{
public:
	virtual ~SmartVector()
	{
		clear();
	}

	/**
	 * Clears all the objects of the container, dynamically deallocting them.
	 */
	virtual void clear()
	{
		size_t i;
		for( i = 0; i < this->size(); i++ )
		{
			delete (*this)[i];
		}
	}
};

#endif // _SMARTLIB_SMARTVECTOR_H_
